package com.service.actions;

import java.util.ArrayList;
import java.util.List;

import javax.management.Query;
import com.googlecode.s2hibernate.struts2.plugin.annotations.SessionTarget;
import com.opensymphony.xwork2.ActionSupport;
import com.service.hibernate.dao.ServiceUsesDAO;
import com.service.hibernate.dao.ServicesDAO;
import com.service.hibernate.pojos.*;

//this class is creating invoice
public class GetInvoiceAction extends ActionSupport {

	private String vehicleNo;
	private float total;
	private List<Stocks> listOfItems = new ArrayList<Stocks>();

	public String execute() {
		ServiceUsesDAO serviceUserDao = new ServiceUsesDAO();
		List<Stocks> list = new ArrayList<Stocks>();
		ServicesDAO sv = new ServicesDAO();
		list = sv.getStockDetial(vehicleNo);
		
		if (list != null) {
			setListOfItems(list);
			//count the total
			setTotal(0);
			for (Stocks d : list) {
				total=total+d.getQuantity()*d.getUnit_price_sel();
			}
		}
		
		return SUCCESS;
	}

	// get set methods
	public String getVehicleNo() {
		return this.vehicleNo;
	}
	public void setVehicleNo(String vehicleNo) {
		this.vehicleNo = vehicleNo;
	}

	public List<Stocks> getListOfItems() {
		return this.listOfItems;
	}
	public void setListOfItems(List<Stocks> list) {
		listOfItems = list;
	}

	public float getTotal() {
		return this.total;
	}
	public void setTotal(float total) {
		this.total=total;
	}

	

}
